// home.js
import { Home } from 'home-model.js';
var home = new Home


Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this._loadData(1);
  },

  _loadData : function(id) {
    home.getBannerByID(id, (items)=>{
          this.setData({"bannerArr":items})
        });

    home.getThemeData((data)=>{
      this.setData({"themeArr": data})
    });

    home.getProductsData((data) => {
      this.setData({"productsArr" : data});
    });
  },

  onProductsItemTap : function(event) {
    var id = home.getDataset(event, 'id');
    wx.navigateTo({
      url : '../product/product?id='+id
    });
  },

  onThemesItemTap : function(event) {
    var id = home.getDataset(event, 'id');
    var name = home.getDataset(event, 'name');

    wx.navigateTo({
      "url" : '../theme/theme?id='+id+'&name='+name
    });
  },

  

})